﻿using AnQinFrameWorkAPI.Entity.Develop.DTO.DevelopProjectCustomer;
using AnQinFrameWorkAPI.Entity.Develop.View.DevelopProjectCustomer;
using AnQinFrameWorkAPI.Service.Develop;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Develop;

/// <summary>
///     开发管理客户列表
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Develop")]
public class DevelopProjectCustomerController : ControllerBase
{
    //业务服务接口
    private readonly DevelopProjectCustomerService _developProjectCustomerService;

    //构造注入
    public DevelopProjectCustomerController(DevelopProjectCustomerService developProjectCustomerService)
    {
        _developProjectCustomerService = developProjectCustomerService;
    }

    /// <summary>
    ///     获取开发管理客户列表
    /// </summary>
    /// <param name="developProjectCustomerSearchDTO"></param>
    [ProducesResponseType(typeof(DevelopProjectCustomerView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetDevelopProjectCustomerList(
        [FromQuery] DevelopProjectCustomerSearchDTO developProjectCustomerSearchDTO)
    {
        var response = await _developProjectCustomerService.GetCustomerList(developProjectCustomerSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增开发管理客户
    /// </summary>
    /// <param name="developProjectCustomerAdd"></param>
    [HttpPost]
    public async Task<IActionResult> AddDevelopProjectCustomer(
        [FromBody] DevelopProjectCustomerAddDTO developProjectCustomerAdd)
    {
        var response = await _developProjectCustomerService.AddCustomer(developProjectCustomerAdd);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新开发管理客户
    /// </summary>
    /// <param name="developProjectCustomerUpdateDTO"></param>
    [HttpPut]
    public async Task<IActionResult> PutDevelopProjectCustomer(
        [FromBody] DevelopProjectCustomerUpdateDTO developProjectCustomerUpdateDTO)
    {
        var response = await _developProjectCustomerService.PutCustomer(developProjectCustomerUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除开发管理客户
    /// </summary>
    /// <param name="deleteDTO"></param>
    [HttpDelete]
    public async Task<IActionResult> DeleteDevelopProjectCustomer([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _developProjectCustomerService.DeleteCustomer(deleteDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     批量删除开发管理客户
    /// </summary>
    /// <param name="idArrayDTO"></param>
    [HttpPost("DeleteMulti")]
    public async Task<IActionResult> DeleteArrayDevelopProjectCustomer([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _developProjectCustomerService.DeleteArrayCustomer(idArrayDTO);
        return StatusCode(response.Status, response);
    }
}